<!DOCTYPE html>
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>highlight.overpassql</title>
<meta name="generator" content="KF5::SyntaxHighlighting - Definition (Overpass QL) - Theme (Breeze Dark)"/>
</head><body style="background-color:#232629;color:#cfcfc2"><pre>
<span style="color:#7a7c7d;">/* Overpass samples taken from</span>
<span style="color:#7a7c7d;">   https://wiki.openstreetmap.org/wiki/Overpass_API/Overpass_QL</span>
<span style="color:#7a7c7d;">   https://wiki.openstreetmap.org/wiki/Overpass_API/Overpass_API_by_Example</span>

*/

<span style="color:#7a7c7d;">// single line comment with </span><span style="color:#ca9219;background-color:#451e1a;font-weight:bold;">TODO</span><span style="color:#7a7c7d;"> alerts</span>

<span style="color:#7a7c7d;">/* multi-line comment with </span><span style="color:#81ca2d;background-color:#4d1f24;font-weight:bold;">###</span><span style="color:#7a7c7d;"> alerts </span>*/

[<span style="color:#8e44ad;">out</span>:json][<span style="color:#27aeae;">timeout</span>:<span style="color:#f67400;">25</span>];
<span style="color:#7a7c7d;">// gather results</span>
(
  <span style="color:#7a7c7d;">// query part for: “amenity=post_box”</span>
  <span style="color:#8e44ad;">node</span>[<span style="color:#f44f4f;">&quot;amenity&quot;</span>=<span style="color:#f44f4f;">&quot;post_box&quot;</span>](<span style="color:#f67400;">52.0</span>, <span style="color:#f67400;">13.0</span>, <span style="color:#f67400;">54.0</span>, <span style="color:#f67400;">13.5</span>);
  <span style="color:#8e44ad;">way</span>[<span style="color:#f44f4f;">&quot;amenity&quot;</span>=<span style="color:#f44f4f;">&quot;post_box&quot;</span>](<span style="color:#27ae60;">{{bbox}}</span>);
  <span style="color:#8e44ad;">relation</span>[<span style="color:#f44f4f;">&quot;amenity&quot;</span>=<span style="color:#f44f4f;">&quot;post_box&quot;</span>](<span style="color:#27ae60;">{{bbox}}</span>);
);
<span style="color:#7a7c7d;">// print results</span>
<span style="color:#8e44ad;">out</span> <span style="color:#7f8c8d;">body</span>;
&gt;;
<span style="color:#8e44ad;">out</span> <span style="color:#7f8c8d;">skel</span> <span style="color:#7f8c8d;">qt</span>;


[<span style="color:#8e44ad;">out</span>:csv(::<span style="color:#7f8c8d;">type</span>, <span style="color:#f44f4f;">&quot;de:regionalschluessel&quot;</span>, name,
         ::<span style="color:#7f8c8d;">count</span>, ::<span style="color:#f44f4f;">&quot;count:nodes&quot;</span>, ::<span style="color:#f44f4f;">&quot;count:ways&quot;</span>, ::<span style="color:#f44f4f;">&quot;count:relations&quot;</span>)];

<span style="color:#7a7c7d;">//All areas with regional key (German: &quot;Regionalschlüssel&quot;) starting with 057</span>
<span style="color:#8e44ad;">area</span>[<span style="color:#f44f4f;">&quot;de:regionalschluessel&quot;</span>~<span style="color:#f44f4f;">&quot;^057&quot;</span>];

<span style="color:#7a7c7d;">// Count the pharmacies in each area</span>
<span style="font-weight:bold;">foreach</span>-&gt;.regio(
  <span style="color:#7a7c7d;">// display details for the current area</span>
  .regio <span style="color:#8e44ad;">out</span>;

  <span style="color:#7a7c7d;">// Collect all Nodes, Ways and Relations with amenity=pharmacy in the current area</span>
  ( <span style="color:#8e44ad;">node</span>(<span style="color:#8e44ad;">area</span>.regio)[amenity=pharmacy];
    <span style="color:#8e44ad;">way</span>(<span style="color:#8e44ad;">area</span>.regio)[amenity=pharmacy];
    <span style="color:#8e44ad;">rel</span>(<span style="color:#8e44ad;">area</span>.regio)[amenity=pharmacy];);

<span style="color:#7a7c7d;">// Count the elements in the current area Area</span>
  <span style="color:#8e44ad;">out</span> <span style="color:#7f8c8d;">count</span>;
);


[<span style="color:#27aeae;">timeout</span>:<span style="color:#f67400;">300</span>]
[<span style="color:#27aeae;">bbox</span>:<span style="color:#f67400;">51.08282186160976</span>,-<span style="color:#f67400;">12.8759765625</span>,<span style="color:#f67400;">55.986091533808384</span>,-<span style="color:#f67400;">1.86767578125</span>]
[<span style="color:#8e44ad;">out</span>:csv(::<span style="color:#7f8c8d;">id</span>, ::<span style="color:#7f8c8d;">type</span>, name, <span style="color:#f44f4f;">&quot;name:en&quot;</span>, <span style="color:#f44f4f;">&quot;name:ga&quot;</span>)];

( <span style="color:#8e44ad;">node</span>[name][<span style="color:#f44f4f;">&quot;name:en&quot;</span>][<span style="color:#f44f4f;">&quot;name:ga&quot;</span>](<span style="font-weight:bold;">if</span>:(t[<span style="color:#f44f4f;">&quot;name&quot;</span>] != t[<span style="color:#f44f4f;">&quot;name:en&quot;</span>]) &amp;&amp; (t[<span style="color:#f44f4f;">&quot;name&quot;</span>] != t[<span style="color:#f44f4f;">&quot;name:ga&quot;</span>]));
  <span style="color:#8e44ad;">way</span>[name][<span style="color:#f44f4f;">&quot;name:en&quot;</span>][<span style="color:#f44f4f;">&quot;name:ga&quot;</span>] (<span style="font-weight:bold;">if</span>:(t[<span style="color:#f44f4f;">&quot;name&quot;</span>] != t[<span style="color:#f44f4f;">&quot;name:en&quot;</span>]) &amp;&amp; (t[<span style="color:#f44f4f;">&quot;name&quot;</span>] != t[<span style="color:#f44f4f;">&quot;name:ga&quot;</span>]));
  <span style="color:#8e44ad;">rel</span>[name][<span style="color:#f44f4f;">&quot;name:en&quot;</span>][<span style="color:#f44f4f;">&quot;name:ga&quot;</span>] (<span style="font-weight:bold;">if</span>:(t[<span style="color:#f44f4f;">&quot;name&quot;</span>] != t[<span style="color:#f44f4f;">&quot;name:en&quot;</span>]) &amp;&amp; (t[<span style="color:#f44f4f;">&quot;name&quot;</span>] != t[<span style="color:#f44f4f;">&quot;name:ga&quot;</span>]));
);
<span style="color:#8e44ad;">out</span>;


[<span style="color:#8e44ad;">out</span>:csv(<span style="color:#7f8c8d;">version</span>,<span style="color:#7f8c8d;">timestamp</span>,<span style="color:#7f8c8d;">changeset</span>,<span style="color:#7f8c8d;">count</span>)];
<span style="color:#8e44ad;">timeline</span>(<span style="color:#8e44ad;">relation</span>,<span style="color:#f67400;">2632934</span>);
<span style="font-weight:bold;">for</span> (t[<span style="color:#f44f4f;">&quot;created&quot;</span>])
{
  <span style="font-weight:bold;">retro</span>(_.val)
  {
    <span style="color:#8e44ad;">rel</span>(<span style="color:#f67400;">2632934</span>);
    <span style="color:#8e44ad;">make</span> stat <span style="color:#7f8c8d;">version</span>=u(<span style="color:#7f8c8d;">version</span>()),<span style="color:#7f8c8d;">timestamp</span>=u(<span style="color:#7f8c8d;">timestamp</span>()),<span style="color:#7f8c8d;">changeset</span>=u(<span style="color:#7f8c8d;">changeset</span>()),<span style="color:#7f8c8d;">count</span>=u(<span style="color:#7f8c8d;">count_members</span>());
    <span style="color:#8e44ad;">out</span>;
  }
}


[<span style="color:#27aeae;">timeout</span>:<span style="color:#f67400;">60</span>];
<span style="color:#8e44ad;">area</span>[<span style="color:#f44f4f;">&quot;name&quot;</span>=<span style="color:#f44f4f;">&quot;Mayenne&quot;</span>]-&gt;.boundaryarea;
<span style="color:#8e44ad;">way</span>(<span style="color:#8e44ad;">area</span>.boundaryarea)[<span style="color:#f44f4f;">&quot;building&quot;</span>=<span style="color:#f44f4f;">&quot;church&quot;</span>];
  <span style="font-weight:bold;">foreach</span>(
    <span style="color:#8e44ad;">node</span>(w)-&gt;.d;                                     <span style="color:#7a7c7d;">// determine all nodes of a way</span>
    .n <span style="color:#8e44ad;">is_in</span>-&gt;.a;
    <span style="color:#8e44ad;">area</span>.a[name][boundary=administrative][admin_level~<span style="color:#f44f4f;">&quot;^[2-8]$&quot;</span>] -&gt; .a;
    <span style="color:#8e44ad;">out</span> <span style="color:#7f8c8d;">center</span>;
    <span style="color:#8e44ad;">convert</span> <span style="color:#8e44ad;">way</span> ::=::,
              ::<span style="color:#7f8c8d;">id</span> = <span style="color:#7f8c8d;">id</span>(),
              <span style="color:#8e44ad;">is_in</span>=a.<span style="color:#7f8c8d;">set</span>(<span style="color:#f44f4f;">&quot;{&quot;</span> + t[<span style="color:#f44f4f;">&quot;admin_level&quot;</span>] + <span style="color:#f44f4f;">&quot;:&quot;</span> + t[<span style="color:#f44f4f;">&quot;name&quot;</span>] + <span style="color:#f44f4f;">&quot;}&quot;</span>);

    <span style="color:#8e44ad;">out</span>;
);
</pre></body></html>
